package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/repair")
public class RepairController {
    @Autowired
    RepairService repairService;

    @GetMapping("select")
    public JsonResult select(RepairQuery repairQuery){
        log.debug("查询维修单，参数={}",repairQuery);
        List<RepairVO> list = repairService.selectRepair(repairQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult save(RepairSaveParam repairSaveParam){
        log.debug("保存维修单，参数={}",repairSaveParam);
        repairService.save(repairSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}/{vehicleId}/{status}")
    public JsonResult deleteRepair(@PathVariable Long id,@PathVariable Long vehicleId,@PathVariable String status){
        log.debug("删除维修单，参数={},{},{}",id,vehicleId,status);
        repairService.deleteRepairById(id,vehicleId,status);
        return JsonResult.ok();
    }
}
